package com.xiaomei.manager.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xiaomei.manager.dao.OrderMapper;
import com.xiaomei.manager.model.Order;
import com.xiaomei.manager.service.IOrderService;
import com.xiaomei.manager.web.dto.OrderDto;
import com.xiaomei.manager.web.dto.req.DayCompleteDto;
import com.xiaomei.manager.web.dto.req.OrderQueryDto;
import com.xiaomei.manager.web.dto.req.QuantityDto;
import com.xiaomei.manager.web.page.Page;

@Service
public class OrderServiceImpl implements IOrderService {
	
	@Autowired
	private OrderMapper orderMapper;

	@Override
	public List<OrderDto> getOrderForList(OrderQueryDto paramDto, Page<OrderDto> page) {
		// TODO Auto-generated method stub
		page.setParamDto(paramDto);
		return orderMapper.selectByParamMap(page);
	}

	@Override
	public Object selectByPrimaryKey(Integer id) {
		// TODO 自动生成的方法存根
		return orderMapper.selectByPrimaryKey(id);
	}
	
	@Override
	public int updateByPrimaryKeySelective(Order order) {
		// TODO 自动生成的方法存根
		return orderMapper.updateByPrimaryKeySelective(order);
	}
	/**
	 * 日下单量
	 * 
	 */
	@Override
	public List<QuantityDto> getQuantity(Page<QuantityDto> page) {
		// TODO Auto-generated method stub
		return orderMapper.selectQuantity(page);
	}
	/**
	 * 日完成量
	 */
	@Override
	public List<DayCompleteDto> getDayComplete(Page<DayCompleteDto> page) {
		// TODO Auto-generated method stub
		return orderMapper.selectDayComplete(page);
	}

	@Override
	public List<QuantityDto> getQuantityCount(String startTime, String endTime) {
		// TODO Auto-generated method stub
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		return orderMapper.selectQuantityCount(map);
	}

	@Override
	public List<DayCompleteDto> selectCompleteCount(String startTime,
			String endTime) {
		// TODO Auto-generated method stub
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		return orderMapper.selectCompleteCount(map);
	}

	@Override
	public int insertSelective(Order record) {
		// TODO Auto-generated method stub
		return orderMapper.insertSelective(record);
	}

}
